package com.example.lsn_opengles713;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

/**
 * 点渲染器,绘制螺旋线
 */
public abstract class AbstractMyRenderer implements android.opengl.GLSurfaceView.Renderer{
	
	public float ratio;
	//
	public float xrotate = 0f;//围绕x轴旋转角度
	public float yrotate = 0f;//围绕x轴旋转角度
	

	/**
	 * 1.
	 */
	public void onSurfaceCreated(GL10 gl, EGLConfig config) {
		//清平色
		gl.glClearColor(0f, 0f, 0f, 1f);
		//启用顶点缓冲区数组
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	}

	/**
	 * 2.
	 */
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		//设置视口
		gl.glViewport(0, 0, width, height);
		ratio = (float)width / (float)height;
		//投影矩阵
		gl.glMatrixMode(GL10.GL_PROJECTION);
		//加载单位矩阵
		gl.glLoadIdentity();
		//设置平截头体
		gl.glFrustumf(-ratio, ratio, -1, 1, 3f, 7f);
	}

	/**
	 * 3.
	 */
	public abstract void onDrawFrame(GL10 gl);
	
	//光照
	public boolean enableLighting = false;
	
	//全局环境光
	public float global$ambient$r = 0.3f;
	public float global$ambient$g = 0.3f;
	public float global$ambient$b = 0.3f;
	public float global$ambient$a = 1f;
	
	//材料的环境光和散射光的反射率
	public float material$ambientanddiffuse$r = 0f ;
	public float material$ambientanddiffuse$g = 0f ;
	public float material$ambientanddiffuse$b = 0f ;
	public float material$ambientanddiffuse$a = 1f ;//

	//是否启用颜色追踪
	public boolean enableColorMatrial = false ;
	public float color$r = 0.8f;
	public float color$g = 0.8f;
	public float color$b = 0.8f;
	public float color$a = 1f;
	
	//是否启用光源0
	public boolean enableLight0 = false ;
	
	//光源0-环境光
	public float light0$ambient$r = 0f;
	public float light0$ambient$g = 0f;
	public float light0$ambient$b = 0f;
	public float light0$ambient$a = 1f;
	//光源0-散射光
	public float light0$diffuse$r = 0f ;
	public float light0$diffuse$g = 0f ;
	public float light0$diffuse$b = 0f ;
	public float light0$diffuse$a = 1f ;
	//光源0-位置
	public float light0$pos$x = 0;
	public float light0$pos$y = 1f;
	public float light0$pos$z = 10f;
	
}
